import 'package:cloudbase_database/cloudbase_database.dart';

class AddressModel {
  Null code;
  Null message;
  List<Data> data;
  String requestId;
  Null total;
  int limit;
  int offset;

  AddressModel(
      {this.code,
      this.message,
      this.data,
      this.requestId,
      this.total,
      this.limit,
      this.offset});

  AddressModel.fromJson(DbQueryResponse json) {
    code = json.code;
    message = json.message;
    if (json.data != null) {
      data = [];
      json.data.forEach((v) {
        data.add(new Data.fromJson(new Map<String, dynamic>.from(v))); // '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>'
      });
    }
    requestId = json.requestId;
    total = json.total;
    limit = json.limit;
    offset = json.offset;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['code'] = this.code;
    data['message'] = this.message;
    if (this.data != null) {
      data['data'] = this.data.map((v) => v.toJson()).toList();
    }
    data['requestId'] = this.requestId;
    data['total'] = this.total;
    data['limit'] = this.limit;
    data['offset'] = this.offset;
    return data;
  }
}

class Data {
  int iCreateTime;
  String sId;
  String sOpenid;
  int iUpdateTime;
  String addressDetail;
  String city;
  int cityId;
  String county;
  int countyId;
  bool isDefault;
  String name;
  String postalCode;
  String province;
  int provinceId;
  String tel;

  Data(
      {this.iCreateTime,
      this.sId,
      this.sOpenid,
      this.iUpdateTime,
      this.addressDetail,
      this.city,
      this.cityId,
      this.county,
      this.countyId,
      this.isDefault,
      this.name,
      this.postalCode,
      this.province,
      this.provinceId,
      this.tel});
  
  Data.fromJson(Map<String, dynamic> json) {
    iCreateTime = json['_createTime'];
    sId = json['_id'];
    sOpenid = json['_openid'];
    iUpdateTime = json['_updateTime'];
    addressDetail = json['addressDetail'];
    city = json['city'];
    cityId = json['cityId'];
    county = json['county'];
    countyId = json['countyId'];
    isDefault = json['isDefault'];
    name = json['name'];
    postalCode = json['postalCode'];
    province = json['province'];
    provinceId = json['provinceId'];
    tel = json['tel'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['_createTime'] = this.iCreateTime;
    data['_id'] = this.sId;
    data['_openid'] = this.sOpenid;
    data['_updateTime'] = this.iUpdateTime;
    data['addressDetail'] = this.addressDetail;
    data['city'] = this.city;
    data['cityId'] = this.cityId;
    data['county'] = this.county;
    data['countyId'] = this.countyId;
    data['isDefault'] = this.isDefault;
    data['name'] = this.name;
    data['postalCode'] = this.postalCode;
    data['province'] = this.province;
    data['provinceId'] = this.provinceId;
    data['tel'] = this.tel;
    return data;
  }
}
